package short_semester.questionnaire_planet.response.AnalyseController;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import short_semester.questionnaire_planet.pojo.FillBlankQuestion;
import short_semester.questionnaire_planet.pojo.MultiChoiceQuestion;
import short_semester.questionnaire_planet.pojo.ScoreQuestion;
import short_semester.questionnaire_planet.pojo.SingleChoiceQuestion;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class QuestionRecordAnalyseResponse {
    String type;
    String title;
    String description;
    Boolean isNecessary;
    Boolean isFinish;
    @JsonIgnore
    Set<Integer> answers = new TreeSet<>();
    String content;
    List<OptionRecordAnalyseResponse> options = new LinkedList<>();
    
    Integer grade;
    String resolution;
    String correctAnswer;
    
    String qtype;
    
    public QuestionRecordAnalyseResponse(SingleChoiceQuestion question){
        type = question.getType();
        title = question.getTitle();
        description = question.getDescription();
        isNecessary = question.getIsNecessary();
        
        grade = question.getGrade();
        resolution = question.getResolution();
        
        qtype=question.getQtype();
    }

    public QuestionRecordAnalyseResponse(MultiChoiceQuestion question){
        type = question.getType();
        title = question.getTitle();
        description = question.getDescription();
        isNecessary = question.getIsNecessary();

        grade = question.getGrade();
        resolution = question.getResolution();

        qtype=question.getQtype();
    }

    public QuestionRecordAnalyseResponse(FillBlankQuestion question){
        type = question.getType();
        title = question.getTitle();
        description=question.getDescription();
        isNecessary = question.getIsNecessary();

        grade = question.getGrade();
        correctAnswer = question.getCorrectAnswer();
        
        qtype=question.getQtype();
    }

    public QuestionRecordAnalyseResponse(ScoreQuestion question){
        type = question.getType();
        title = question.getTitle();
        description = question.getDescription();
        isNecessary = question.getIsNecessary();

        qtype=question.getQtype();
    }
}
